package com.alex.statistics.pojo.result.spatialAnalysis;


import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Schema(description = "核密度估计结果")
@AllArgsConstructor
@NoArgsConstructor
public class KernelDensityResult {
    /* ------------ 元数据 ------------ */
    @Schema(description = "计算耗时(ms)")
    private long computeTime;

    @Schema(description = "网格实际范围[xMin, xMax, yMin, yMax]")
    private double[] bounds;

    @Schema(description = "密度值范围[min, max]")
    private double[] valueRange;

    /* ------------ 热力图数据 ------------ */
    @Schema(description = "ECharts热力图数据")
    private List<HeatmapPoint> heatmap;
    @Schema(description = "Openlayers热力图数据")
    private List<HeatmapPointOpenlayers> heatmapOpenlayers;


    /* ------------ 原始数据（可选） ------------ */
    @Schema(description = "原始密度矩阵（行优先）")
    private double[] rawMatrix;

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "热力图数据点")
    public static class HeatmapPoint {
        @Schema(description = "网格X索引")
        private int x;

        @Schema(description = "网格Y索引")
        private int y;

        @Schema(description = "密度值")
        private double value;

        @Schema(description = "实际X坐标")
        private double realX;

        @Schema(description = "实际Y坐标")
        private double realY;

    }

    /**
     * 新增OpenLayers热力图数据点（含网格边界）
     */
    @Data
     @AllArgsConstructor
    @NoArgsConstructor
    public static class HeatmapPointOpenlayers {
        private int gridX;      // 网格X索引
        private int gridY;      // 网格Y索引
        private double density; // 密度值
        private double centerLon; // 中心点经度
        private double centerLat; // 中心点纬度
        private double minLon;  // 网格左边界经度
        private double maxLon;  // 网格右边界经度
        private double minLat;  // 网格下边界纬度
        private double maxLat;  // 网格上边界纬度
    }
}